<?php
/**
 * @file $HeadURL: question.php $
 * @author $Author: Zhe.Zhou (zhouzhe@haibao.com) $
 * @date $Date: 2015-4-16 15:32:05 $
 * @
 */
namespace haibao\cms\business;
use haibao\cms\business\BusinessException;
use \haibao\cms\data\Question as QuestionData; 

class Question extends \haibao\cms\business\Base{	
	public static function getQuestionById($questionId){
		if(!$questionId){
			return NULL;
		}
		$questionData = new QuestionData();
		return $questionData->getModelById($questionId);
	}
	public static function getQuestionList($questionFilter,$source = \haibao\cms\model\data\Question::SOURCE_PC){
		if($source == \haibao\cms\model\data\Question::SOURCE_PC){
			self::checkOperation(self::FUNC_CODE_QUESTION_LIST);
		}else{
			self::checkOperation(self::FUNC_CODE_M_QUESTION_LIST);
		}
		$questionData = new QuestionData();
		return $questionData->getQuestionList($questionFilter);
	}
	public static function addQuestion($model){
		$questionData = new QuestionData();
		$questionData->add($model);
	}
	
	public static function getCacheCountByIp($ip){
		$questionData = new QuestionData();
		return $questionData->getCacheCountByIp($ip);
	}
	
	public static function setCacheIpCount($ip, $count){
		$questionData = new QuestionData();
		$questionData->setCacheIpCount($ip, $count);
	}
	
	public static function delQuestion($id){
		self::checkOperation(self::FUNC_CODE_QUESTION_DEL);
		if (!$id){
			throw new BusinessException('Question_Id不能为空');
		}
		$questionData = new QuestionData();
		$questionData->delQuestion($id,\haibao\cms\model\data\Question::STATUS_DELETE);
	}
	
}
